package com.qf.controller;

import com.qf.annotations.RequestMapping;
import com.qf.pojo.TbAddress1;
import com.qf.service.Impl.dizhiserviceImpl;
import com.qf.service.dizhiservice;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.ws.Action;

@RequestMapping("/address")
public class dizhi {

    private dizhiservice dizhiservice;

    @Resource
    public void dizhiservice(dizhiservice dizhiservice){
        this.dizhiservice = dizhiservice;
    }

    @RequestMapping("/add")
    public String adddizhi(HttpServletRequest request, HttpServletResponse response){
        String detail = request.getParameter("detail");
        String name = request.getParameter("name");
        String phone = request.getParameter("phone");
        Integer uid = Integer.valueOf(request.getParameter("uid"));
        Integer level = Integer.valueOf(request.getParameter("level"));

        TbAddress1 tbAddress = new TbAddress1(0, detail, name, phone, uid, level);


        dizhiservice.adddizhi(tbAddress);

        return "redirect:/order/preView";
    }

    @RequestMapping("/deletes")
    public void deletes(HttpServletRequest request, HttpServletResponse response){
        Integer id = Integer.valueOf(request.getParameter("id"));
        dizhiservice.deletedizhi(id);
    }
    @RequestMapping("/updates")
    public void updates(HttpServletRequest request, HttpServletResponse response){
        String detail = request.getParameter("detail");
        String name = request.getParameter("name");
        String phone = request.getParameter("phone");
        Integer uid = Integer.valueOf(request.getParameter("uid"));
        Integer level = Integer.valueOf(request.getParameter("level"));
        Integer id = Integer.valueOf(request.getParameter("id"));

        TbAddress1 tbAddress1 = new TbAddress1(id,detail,name,phone,uid,level);
        dizhiservice.updatedizhi(tbAddress1);
    }
}
